package twistter;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.BevelBorder;

public class TweetPanel extends JPanel {
	
	private Tweet myTweet;
	
	private JButton btnFav;

	public TweetPanel(Tweet t) {
		
		this.myTweet = t;
		
		ImageIcon icon = new ImageIcon(this.myTweet.getImage());
		icon.getImage().getScaledInstance(Tweet.imageSize.width, Tweet.imageSize.height, Image.SCALE_SMOOTH);
		JLabel lblImage = new JLabel(icon);
		lblImage.setPreferredSize(Tweet.imageSize);
		JLabel lblName = new JLabel(this.myTweet.getName());
		lblName.setFont(lblName.getFont().deriveFont(Font.BOLD));
		lblName.setMaximumSize(new Dimension(400,80));
		JLabel lblContent = new JLabel(this.myTweet.getContent());
		ImageIcon favIcon = new ImageIcon("fav.png");
		//favIcon.getImage().getScaledInstance(20, 20, Image.SCALE_SMOOTH);
		this.btnFav = new JButton(favIcon);
		this.btnFav.setSize(20,20);
		this.btnFav.setMaximumSize(this.btnFav.getSize());
		//lblImage.setLayout(new BoxLayout(lblImage, BoxLayout.X_AXIS));
		//lblName.setLayout(new BoxLayout(lblName, BoxLayout.X_AXIS));
		//lblContent.setLayout(new BoxLayout(lblContent, BoxLayout.X_AXIS));
		this.setLayout(new BorderLayout());
		JPanel pnlContent = new JPanel();
		pnlContent.setLayout(new BorderLayout());
		this.add(lblImage, BorderLayout.WEST);
		pnlContent.add(lblName, BorderLayout.NORTH);
		pnlContent.add(lblContent, BorderLayout.CENTER);
		pnlContent.add(this.btnFav, BorderLayout.EAST);
		this.add(pnlContent);
		
		this.setBorder(new BevelBorder(BevelBorder.RAISED));
		this.setMaximumSize(new Dimension(1000,80)); // COMME MA BITE
	}
	
	public Tweet getTweet() { return this.myTweet; }
	public JButton getBtnFav() { return this.btnFav; }

}